<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The University of Glasgow 2006
(c) The AQUA Project, Glasgow University, 1994-1998


Desugaring foreign calls
-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-10"></span><span>
</span><span id="line-11"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}</span><span>
</span><span id="line-12"></span><span>
</span><span id="line-13"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.HsToCore.Foreign.Call</span><span>
</span><span id="line-14"></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html#dsCCall"><span class="hs-identifier">dsCCall</span></a></span><span>
</span><span id="line-15"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html#mkFCall"><span class="hs-identifier">mkFCall</span></a></span><span>
</span><span id="line-16"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html#unboxArg"><span class="hs-identifier">unboxArg</span></a></span><span>
</span><span id="line-17"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html#boxResult"><span class="hs-identifier">boxResult</span></a></span><span>
</span><span id="line-18"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html#resultWrapper"><span class="hs-identifier">resultWrapper</span></a></span><span>
</span><span id="line-19"></span><span>   </span><span class="hs-special">)</span><span>
</span><span id="line-20"></span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.HsToCore.Monad.html"><span class="hs-identifier">GHC.HsToCore.Monad</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html"><span class="hs-identifier">GHC.Core.Utils</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Make.html"><span class="hs-identifier">GHC.Core.Make</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.Make.html"><span class="hs-identifier">GHC.Types.Id.Make</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html"><span class="hs-identifier">GHC.Types.ForeignCall</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.HsToCore.Utils.html"><span class="hs-identifier">GHC.HsToCore.Utils</span></a></span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html"><span class="hs-identifier">GHC.Tc.Utils.TcType</span></a></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Multiplicity.html"><span class="hs-identifier">GHC.Core.Multiplicity</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier">Id</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.PrimOps.html"><span class="hs-identifier">GHC.Builtin.PrimOps</span></a></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.Prim.html"><span class="hs-identifier">GHC.Builtin.Types.Prim</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html"><span class="hs-identifier">GHC.Builtin.Types</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Literal.html"><span class="hs-identifier">GHC.Types.Literal</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html"><span class="hs-identifier">GHC.Builtin.Names</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-53"></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#"><span class="hs-identifier">Data.Maybe</span></a></span><span>
</span><span id="line-55"></span><span>
</span><span id="line-56"></span><span class="hs-comment">{-
Desugaring of @ccall@s consists of adding some state manipulation,
unboxing any boxed primitive arguments and boxing the result if
desired.

The state stuff just consists of adding in
@PrimIO (\ s -&gt; case s of { State# s# -&gt; ... })@ in an appropriate place.

The unboxing is straightforward, as all information needed to unbox is
available from the type.  For each boxed-primitive argument, we
transform:
\begin{verbatim}
   _ccall_ foo [ r, t1, ... tm ] e1 ... em
   |
   |
   V
   case e1 of { T1# x1# -&gt;
   ...
   case em of { Tm# xm# -&gt; xm#
   ccall# foo [ r, t1#, ... tm# ] x1# ... xm#
   } ... }
\end{verbatim}

The reboxing of a @_ccall_@ result is a bit tricker: the types don't
contain information about the state-pairing functions so we have to
keep a list of \tr{(type, s-p-function)} pairs.  We transform as
follows:
\begin{verbatim}
   ccall# foo [ r, t1#, ... tm# ] e1# ... em#
   |
   |
   V
   \ s# -&gt; case (ccall# foo [ r, t1#, ... tm# ] s# e1# ... em#) of
          (StateAnd&lt;r&gt;# result# state#) -&gt; (R# result#, realWorld#)
\end{verbatim}
-}</span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html#dsCCall"><span class="hs-identifier hs-type">dsCCall</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#CLabelString"><span class="hs-identifier hs-type">CLabelString</span></a></span><span> </span><span class="hs-comment">-- C routine to invoke</span><span>
</span><span id="line-94"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">]</span><span>   </span><span class="hs-comment">-- Arguments (desugared)</span><span>
</span><span id="line-95"></span><span>                        </span><span class="hs-comment">-- Precondition: none have levity-polymorphic types</span><span>
</span><span id="line-96"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#Safety"><span class="hs-identifier hs-type">Safety</span></a></span><span>       </span><span class="hs-comment">-- Safety of the call</span><span>
</span><span id="line-97"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>         </span><span class="hs-comment">-- Type of the result: IO t</span><span>
</span><span id="line-98"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-comment">-- Result, of type ???</span><span>
</span><span id="line-99"></span><span>
</span><span id="line-100"></span><span id="dsCCall"><span class="annot"><span class="annottext">dsCCall :: CLabelString -&gt; [CoreExpr] -&gt; Safety -&gt; Type -&gt; DsM CoreExpr
</span><a href="GHC.HsToCore.Foreign.Call.html#dsCCall"><span class="hs-identifier hs-var hs-var">dsCCall</span></a></span></span><span> </span><span id="local-6989586621681188771"><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681188771"><span class="hs-identifier hs-var">lbl</span></a></span></span><span> </span><span id="local-6989586621681188770"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681188770"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621681188769"><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681188769"><span class="hs-identifier hs-var">may_gc</span></a></span></span><span> </span><span id="local-6989586621681188768"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188768"><span class="hs-identifier hs-var">result_ty</span></a></span></span><span>
</span><span id="line-101"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681188767"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681188767"><span class="hs-identifier hs-var">unboxed_args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188766"><span class="annot"><span class="annottext">[CoreExpr -&gt; CoreExpr]
</span><a href="#local-6989586621681188766"><span class="hs-identifier hs-var">arg_wrappers</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CoreExpr
 -&gt; IOEnv (Env DsGblEnv DsLclEnv) (CoreExpr, CoreExpr -&gt; CoreExpr))
-&gt; [CoreExpr]
-&gt; IOEnv
     (Env DsGblEnv DsLclEnv) ([CoreExpr], [CoreExpr -&gt; CoreExpr])
forall (m :: * -&gt; *) a b c.
Applicative m =&gt;
(a -&gt; m (b, c)) -&gt; [a] -&gt; m ([b], [c])
</span><a href="../../base/src/Control.Monad.html#mapAndUnzipM"><span class="hs-identifier hs-var">mapAndUnzipM</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (CoreExpr, CoreExpr -&gt; CoreExpr)
</span><a href="GHC.HsToCore.Foreign.Call.html#unboxArg"><span class="hs-identifier hs-var">unboxArg</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681188770"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-102"></span><span>       </span><span class="hs-special">(</span><span id="local-6989586621681188764"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188764"><span class="hs-identifier hs-var">ccall_result_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188763"><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188763"><span class="hs-identifier hs-var">res_wrapper</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM (Type, CoreExpr -&gt; CoreExpr)
</span><a href="GHC.HsToCore.Foreign.Call.html#boxResult"><span class="hs-identifier hs-var">boxResult</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188768"><span class="hs-identifier hs-var">result_ty</span></a></span><span>
</span><span id="line-103"></span><span>       </span><span id="local-6989586621681188762"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681188762"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf DsGblEnv DsLclEnv Unique
forall gbl lcl. TcRnIf gbl lcl Unique
</span><a href="GHC.Tc.Utils.Monad.html#newUnique"><span class="hs-identifier hs-var">newUnique</span></a></span><span>
</span><span id="line-104"></span><span>       </span><span id="local-6989586621681188760"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681188760"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-105"></span><span>       </span><span class="hs-keyword">let</span><span>
</span><span id="line-106"></span><span>           </span><span id="local-6989586621681188758"><span class="annot"><span class="annottext">target :: CCallTarget
</span><a href="#local-6989586621681188758"><span class="hs-identifier hs-var hs-var">target</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SourceText -&gt; CLabelString -&gt; Maybe Unit -&gt; Bool -&gt; CCallTarget
</span><a href="GHC.Types.ForeignCall.html#StaticTarget"><span class="hs-identifier hs-var">StaticTarget</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><a href="GHC.Types.Basic.html#NoSourceText"><span class="hs-identifier hs-var">NoSourceText</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681188771"><span class="hs-identifier hs-var">lbl</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Unit
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-107"></span><span>           </span><span id="local-6989586621681188755"><span class="annot"><span class="annottext">the_fcall :: ForeignCall
</span><a href="#local-6989586621681188755"><span class="hs-identifier hs-var hs-var">the_fcall</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CCallSpec -&gt; ForeignCall
</span><a href="GHC.Types.ForeignCall.html#CCall"><span class="hs-identifier hs-var">CCall</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CCallTarget -&gt; CCallConv -&gt; Safety -&gt; CCallSpec
</span><a href="GHC.Types.ForeignCall.html#CCallSpec"><span class="hs-identifier hs-var">CCallSpec</span></a></span><span> </span><span class="annot"><span class="annottext">CCallTarget
</span><a href="#local-6989586621681188758"><span class="hs-identifier hs-var">target</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#CCallConv"><span class="hs-identifier hs-var">CCallConv</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681188769"><span class="hs-identifier hs-var">may_gc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-108"></span><span>           </span><span id="local-6989586621681188751"><span class="annot"><span class="annottext">the_prim_app :: CoreExpr
</span><a href="#local-6989586621681188751"><span class="hs-identifier hs-var hs-var">the_prim_app</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Unique -&gt; ForeignCall -&gt; [CoreExpr] -&gt; Type -&gt; CoreExpr
</span><a href="GHC.HsToCore.Foreign.Call.html#mkFCall"><span class="hs-identifier hs-var">mkFCall</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681188760"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681188762"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignCall
</span><a href="#local-6989586621681188755"><span class="hs-identifier hs-var">the_fcall</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681188767"><span class="hs-identifier hs-var">unboxed_args</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188764"><span class="hs-identifier hs-var">ccall_result_ty</span></a></span><span>
</span><span id="line-109"></span><span>       </span><span class="annot"><span class="annottext">CoreExpr -&gt; DsM CoreExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((CoreExpr -&gt; CoreExpr) -&gt; CoreExpr -&gt; CoreExpr)
-&gt; CoreExpr -&gt; [CoreExpr -&gt; CoreExpr] -&gt; CoreExpr
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr) -&gt; CoreExpr -&gt; CoreExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">($)</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188763"><span class="hs-identifier hs-var">res_wrapper</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188751"><span class="hs-identifier hs-var">the_prim_app</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExpr -&gt; CoreExpr]
</span><a href="#local-6989586621681188766"><span class="hs-identifier hs-var">arg_wrappers</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-110"></span><span>
</span><span id="line-111"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html#mkFCall"><span class="hs-identifier hs-type">mkFCall</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html#Unique"><span class="hs-identifier hs-type">Unique</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#ForeignCall"><span class="hs-identifier hs-type">ForeignCall</span></a></span><span>
</span><span id="line-112"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">]</span><span>     </span><span class="hs-comment">-- Args</span><span>
</span><span id="line-113"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>           </span><span class="hs-comment">-- Result type</span><span>
</span><span id="line-114"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-115"></span><span class="hs-comment">-- Construct the ccall.  The only tricky bit is that the ccall Id should have</span><span>
</span><span id="line-116"></span><span class="hs-comment">-- no free vars, so if any of the arg tys do we must give it a polymorphic type.</span><span>
</span><span id="line-117"></span><span class="hs-comment">--      [I forget *why* it should have no free vars!]</span><span>
</span><span id="line-118"></span><span class="hs-comment">-- For example:</span><span>
</span><span id="line-119"></span><span class="hs-comment">--      mkCCall ... [s::StablePtr (a-&gt;b), x::Addr, c::Char]</span><span>
</span><span id="line-120"></span><span class="hs-comment">--</span><span>
</span><span id="line-121"></span><span class="hs-comment">-- Here we build a ccall thus</span><span>
</span><span id="line-122"></span><span class="hs-comment">--      (ccallid::(forall a b.  StablePtr (a -&gt; b) -&gt; Addr -&gt; Char -&gt; IO Addr))</span><span>
</span><span id="line-123"></span><span class="hs-comment">--                      a b s x c</span><span>
</span><span id="line-124"></span><span id="mkFCall"><span class="annot"><span class="annottext">mkFCall :: DynFlags -&gt; Unique -&gt; ForeignCall -&gt; [CoreExpr] -&gt; Type -&gt; CoreExpr
</span><a href="GHC.HsToCore.Foreign.Call.html#mkFCall"><span class="hs-identifier hs-var hs-var">mkFCall</span></a></span></span><span> </span><span id="local-6989586621681188749"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681188749"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681188748"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681188748"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span id="local-6989586621681188747"><span class="annot"><span class="annottext">ForeignCall
</span><a href="#local-6989586621681188747"><span class="hs-identifier hs-var">the_fcall</span></a></span></span><span> </span><span id="local-6989586621681188746"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681188746"><span class="hs-identifier hs-var">val_args</span></a></span></span><span> </span><span id="local-6989586621681188745"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188745"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span>
</span><span id="line-125"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">all</span><span> </span><span class="hs-identifier">isTyVar</span><span> </span><span class="hs-identifier">tyvars</span><span> </span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- this must be true because the type is top-level</span><span>
</span><span id="line-126"></span><span>    </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
forall b. Expr b -&gt; [Expr b] -&gt; Expr b
</span><a href="GHC.Core.html#mkApps"><span class="hs-identifier hs-var">mkApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; [Var] -&gt; CoreExpr
forall b. Expr b -&gt; [Var] -&gt; Expr b
</span><a href="GHC.Core.html#mkVarApps"><span class="hs-identifier hs-var">mkVarApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188734"><span class="hs-identifier hs-var">the_fcall_id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Var]
</span><a href="#local-6989586621681188739"><span class="hs-identifier hs-var">tyvars</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681188746"><span class="hs-identifier hs-var">val_args</span></a></span><span>
</span><span id="line-127"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-128"></span><span>    </span><span id="local-6989586621681188733"><span class="annot"><span class="annottext">arg_tys :: [Type]
</span><a href="#local-6989586621681188733"><span class="hs-identifier hs-var hs-var">arg_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; Type) -&gt; [CoreExpr] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Type
</span><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier hs-var">exprType</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681188746"><span class="hs-identifier hs-var">val_args</span></a></span><span>
</span><span id="line-129"></span><span>    </span><span id="local-6989586621681188731"><span class="annot"><span class="annottext">body_ty :: Type
</span><a href="#local-6989586621681188731"><span class="hs-identifier hs-var hs-var">body_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTysMany"><span class="hs-identifier hs-var">mkVisFunTysMany</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681188733"><span class="hs-identifier hs-var">arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188745"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-130"></span><span>    </span><span id="local-6989586621681188739"><span class="annot"><span class="annottext">tyvars :: [Var]
</span><a href="#local-6989586621681188739"><span class="hs-identifier hs-var hs-var">tyvars</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; [Var]
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypeWellScoped"><span class="hs-identifier hs-var">tyCoVarsOfTypeWellScoped</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188731"><span class="hs-identifier hs-var">body_ty</span></a></span><span>
</span><span id="line-131"></span><span>    </span><span id="local-6989586621681188728"><span class="annot"><span class="annottext">ty :: Type
</span><a href="#local-6989586621681188728"><span class="hs-identifier hs-var hs-var">ty</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Var] -&gt; Type -&gt; Type
</span><a href="GHC.Core.Type.html#mkInfForAllTys"><span class="hs-identifier hs-var">mkInfForAllTys</span></a></span><span> </span><span class="annot"><span class="annottext">[Var]
</span><a href="#local-6989586621681188739"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188731"><span class="hs-identifier hs-var">body_ty</span></a></span><span>
</span><span id="line-132"></span><span>    </span><span id="local-6989586621681188734"><span class="annot"><span class="annottext">the_fcall_id :: Var
</span><a href="#local-6989586621681188734"><span class="hs-identifier hs-var hs-var">the_fcall_id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Unique -&gt; ForeignCall -&gt; Type -&gt; Var
</span><a href="GHC.Types.Id.Make.html#mkFCallId"><span class="hs-identifier hs-var">mkFCallId</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681188749"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681188748"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignCall
</span><a href="#local-6989586621681188747"><span class="hs-identifier hs-var">the_fcall</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188728"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-133"></span><span>
</span><span id="line-134"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html#unboxArg"><span class="hs-identifier hs-type">unboxArg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>                    </span><span class="hs-comment">-- The supplied argument, not levity-polymorphic</span><span>
</span><span id="line-135"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">,</span><span>              </span><span class="hs-comment">-- To pass as the actual argument</span><span>
</span><span id="line-136"></span><span>                 </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>   </span><span class="hs-comment">-- Wrapper to unbox the arg</span><span>
</span><span id="line-137"></span><span>                </span><span class="hs-special">)</span><span>
</span><span id="line-138"></span><span class="hs-comment">-- Example: if the arg is e::Int, unboxArg will return</span><span>
</span><span id="line-139"></span><span class="hs-comment">--      (x#::Int#, \W. case x of I# x# -&gt; W)</span><span>
</span><span id="line-140"></span><span class="hs-comment">-- where W is a CoreExpr that probably mentions x#</span><span>
</span><span id="line-141"></span><span>
</span><span id="line-142"></span><span class="hs-comment">-- always returns a non-levity-polymorphic expression</span><span>
</span><span id="line-143"></span><span>
</span><span id="line-144"></span><span id="unboxArg"><span class="annot"><span class="annottext">unboxArg :: CoreExpr
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (CoreExpr, CoreExpr -&gt; CoreExpr)
</span><a href="GHC.HsToCore.Foreign.Call.html#unboxArg"><span class="hs-identifier hs-var hs-var">unboxArg</span></a></span></span><span> </span><span id="local-6989586621681188725"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188725"><span class="hs-identifier hs-var">arg</span></a></span></span><span>
</span><span id="line-145"></span><span>  </span><span class="hs-comment">-- Primitive types: nothing to unbox</span><span>
</span><span id="line-146"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Type.html#isPrimitiveType"><span class="hs-identifier hs-var">isPrimitiveType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188723"><span class="hs-identifier hs-var">arg_ty</span></a></span><span>
</span><span id="line-147"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExpr, CoreExpr -&gt; CoreExpr)
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (CoreExpr, CoreExpr -&gt; CoreExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188725"><span class="hs-identifier hs-var">arg</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681188722"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188722"><span class="hs-identifier hs-var">body</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188722"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-148"></span><span>
</span><span id="line-149"></span><span>  </span><span class="hs-comment">-- Recursive newtypes</span><span>
</span><span id="line-150"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span class="hs-special">(</span><span id="local-6989586621681188721"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188721"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188720"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188720"><span class="hs-identifier hs-var">_rep_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Coercion, Type)
</span><a href="GHC.Core.Coercion.html#topNormaliseNewType_maybe"><span class="hs-identifier hs-var">topNormaliseNewType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188723"><span class="hs-identifier hs-var">arg_ty</span></a></span><span>
</span><span id="line-151"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (CoreExpr, CoreExpr -&gt; CoreExpr)
</span><a href="GHC.HsToCore.Foreign.Call.html#unboxArg"><span class="hs-identifier hs-var">unboxArg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; Coercion -&gt; CoreExpr
</span><a href="GHC.HsToCore.Utils.html#mkCastDs"><span class="hs-identifier hs-var">mkCastDs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188725"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188721"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-152"></span><span>
</span><span id="line-153"></span><span>  </span><span class="hs-comment">-- Booleans</span><span>
</span><span id="line-154"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681188717"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188717"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe TyCon
</span><a href="GHC.Core.Type.html#tyConAppTyCon_maybe"><span class="hs-identifier hs-var">tyConAppTyCon_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188723"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-155"></span><span>    </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188717"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#boolTyConKey"><span class="hs-identifier hs-var">boolTyConKey</span></a></span><span>
</span><span id="line-156"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681188713"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681188713"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-157"></span><span>       </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681188712"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681188712"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681188713"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-158"></span><span>       </span><span id="local-6989586621681188710"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188710"><span class="hs-identifier hs-var">prim_arg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; DsM Var
</span><a href="GHC.HsToCore.Monad.html#newSysLocalDs"><span class="hs-identifier hs-var">newSysLocalDs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#intPrimTy"><span class="hs-identifier hs-var">intPrimTy</span></a></span><span>
</span><span id="line-159"></span><span>       </span><span class="annot"><span class="annottext">(CoreExpr, CoreExpr -&gt; CoreExpr)
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (CoreExpr, CoreExpr -&gt; CoreExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188710"><span class="hs-identifier hs-var">prim_arg</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-160"></span><span>              </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621681188706"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188706"><span class="hs-identifier hs-var">body</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Var -&gt; Type -&gt; [Alt Var] -&gt; CoreExpr
forall b. Expr b -&gt; b -&gt; Type -&gt; [Alt b] -&gt; Expr b
</span><a href="GHC.Core.html#Case"><span class="hs-identifier hs-var">Case</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Make.html#mkIfThenElse"><span class="hs-identifier hs-var">mkIfThenElse</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188725"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Integer -&gt; CoreExpr
forall b. Platform -&gt; Integer -&gt; Expr b
</span><a href="GHC.Core.html#mkIntLit"><span class="hs-identifier hs-var">mkIntLit</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681188712"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Integer -&gt; CoreExpr
forall b. Platform -&gt; Integer -&gt; Expr b
</span><a href="GHC.Core.html#mkIntLit"><span class="hs-identifier hs-var">mkIntLit</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681188712"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-161"></span><span>                             </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188710"><span class="hs-identifier hs-var">prim_arg</span></a></span><span>
</span><span id="line-162"></span><span>                             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; Type
</span><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier hs-var">exprType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188706"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-163"></span><span>                             </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="GHC.Core.html#DEFAULT"><span class="hs-identifier hs-var">DEFAULT</span></a></span><span class="hs-special">,</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188706"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-164"></span><span>
</span><span id="line-165"></span><span>  </span><span class="hs-comment">-- Data types with a single constructor, which has a single, primitive-typed arg</span><span>
</span><span id="line-166"></span><span>  </span><span class="hs-comment">-- This deals with Int, Float etc; also Ptr, ForeignPtr</span><span>
</span><span id="line-167"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681188701"><span class="hs-identifier hs-var">is_product_type</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681188700"><span class="hs-identifier hs-var">data_con_arity</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-168"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span class="hs-identifier">isUnliftedType</span><span> </span><span class="hs-identifier">data_con_arg_ty1</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">pprType</span><span> </span><span class="hs-identifier">arg_ty</span><span class="hs-special">)</span><span>
</span><span id="line-169"></span><span>                        </span><span class="hs-comment">-- Typechecker ensures this</span><span>
</span><span id="line-170"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681188695"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188695"><span class="hs-identifier hs-var">case_bndr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; DsM Var
</span><a href="GHC.HsToCore.Monad.html#newSysLocalDs"><span class="hs-identifier hs-var">newSysLocalDs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188723"><span class="hs-identifier hs-var">arg_ty</span></a></span><span>
</span><span id="line-171"></span><span>       </span><span id="local-6989586621681188694"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188694"><span class="hs-identifier hs-var">prim_arg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; DsM Var
</span><a href="GHC.HsToCore.Monad.html#newSysLocalDs"><span class="hs-identifier hs-var">newSysLocalDs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188698"><span class="hs-identifier hs-var">data_con_arg_ty1</span></a></span><span>
</span><span id="line-172"></span><span>       </span><span class="annot"><span class="annottext">(CoreExpr, CoreExpr -&gt; CoreExpr)
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (CoreExpr, CoreExpr -&gt; CoreExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188694"><span class="hs-identifier hs-var">prim_arg</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-173"></span><span>               </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621681188693"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188693"><span class="hs-identifier hs-var">body</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Var -&gt; Type -&gt; [Alt Var] -&gt; CoreExpr
forall b. Expr b -&gt; b -&gt; Type -&gt; [Alt b] -&gt; Expr b
</span><a href="GHC.Core.html#Case"><span class="hs-identifier hs-var">Case</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188725"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188695"><span class="hs-identifier hs-var">case_bndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; Type
</span><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier hs-var">exprType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188693"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; AltCon
</span><a href="GHC.Core.html#DataAlt"><span class="hs-identifier hs-var">DataAlt</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681188691"><span class="hs-identifier hs-var">data_con</span></a></span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188694"><span class="hs-identifier hs-var">prim_arg</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188693"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-174"></span><span>              </span><span class="hs-special">)</span><span>
</span><span id="line-175"></span><span>
</span><span id="line-176"></span><span>  </span><span class="hs-comment">-- Byte-arrays, both mutable and otherwise; hack warning</span><span>
</span><span id="line-177"></span><span>  </span><span class="hs-comment">-- We're looking for values of type ByteArray, MutableByteArray</span><span>
</span><span id="line-178"></span><span>  </span><span class="hs-comment">--    data ByteArray          ix = ByteArray        ix ix ByteArray#</span><span>
</span><span id="line-179"></span><span>  </span><span class="hs-comment">--    data MutableByteArray s ix = MutableByteArray ix ix (MutableByteArray# s)</span><span>
</span><span id="line-180"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681188701"><span class="hs-identifier hs-var">is_product_type</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-181"></span><span>    </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681188700"><span class="hs-identifier hs-var">data_con_arity</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-182"></span><span>    </span><span class="annot"><span class="annottext">Maybe TyCon -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TyCon
</span><a href="#local-6989586621681188689"><span class="hs-identifier hs-var">maybe_arg3_tycon</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-183"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188688"><span class="hs-identifier hs-var">arg3_tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span>  </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#byteArrayPrimTyCon"><span class="hs-identifier hs-var">byteArrayPrimTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-184"></span><span>     </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188688"><span class="hs-identifier hs-var">arg3_tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span>  </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#mutableByteArrayPrimTyCon"><span class="hs-identifier hs-var">mutableByteArrayPrimTyCon</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-185"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681188684"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188684"><span class="hs-identifier hs-var">case_bndr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; DsM Var
</span><a href="GHC.HsToCore.Monad.html#newSysLocalDs"><span class="hs-identifier hs-var">newSysLocalDs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188723"><span class="hs-identifier hs-var">arg_ty</span></a></span><span>
</span><span id="line-186"></span><span>       </span><span id="local-6989586621681188683"><span class="annot"><span class="annottext">vars :: [Var]
</span><a href="#local-6989586621681188683"><span class="hs-identifier hs-var">vars</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">[</span><span id="local-6989586621681188682"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188682"><span class="hs-identifier hs-var">_l_var</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188681"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188681"><span class="hs-identifier hs-var">_r_var</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188680"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188680"><span class="hs-identifier hs-var">arr_cts_var</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Scaled Type] -&gt; DsM [Var]
</span><a href="GHC.HsToCore.Monad.html#newSysLocalsDs"><span class="hs-identifier hs-var">newSysLocalsDs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type -&gt; Scaled Type) -&gt; [Type] -&gt; [Scaled Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Scaled Type
forall a. a -&gt; Scaled a
</span><a href="GHC.Core.Type.html#unrestricted"><span class="hs-identifier hs-var">unrestricted</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681188677"><span class="hs-identifier hs-var">data_con_arg_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-187"></span><span>       </span><span class="annot"><span class="annottext">(CoreExpr, CoreExpr -&gt; CoreExpr)
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (CoreExpr, CoreExpr -&gt; CoreExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188680"><span class="hs-identifier hs-var">arr_cts_var</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-188"></span><span>               </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621681188676"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188676"><span class="hs-identifier hs-var">body</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Var -&gt; Type -&gt; [Alt Var] -&gt; CoreExpr
forall b. Expr b -&gt; b -&gt; Type -&gt; [Alt b] -&gt; Expr b
</span><a href="GHC.Core.html#Case"><span class="hs-identifier hs-var">Case</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188725"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188684"><span class="hs-identifier hs-var">case_bndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; Type
</span><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier hs-var">exprType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188676"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; AltCon
</span><a href="GHC.Core.html#DataAlt"><span class="hs-identifier hs-var">DataAlt</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681188691"><span class="hs-identifier hs-var">data_con</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Var]
</span><a href="#local-6989586621681188683"><span class="hs-identifier hs-var">vars</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188676"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-189"></span><span>              </span><span class="hs-special">)</span><span>
</span><span id="line-190"></span><span>
</span><span id="line-191"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-192"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681188675"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681188675"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DsM SrcSpan
</span><a href="GHC.HsToCore.Monad.html#getSrcSpanDs"><span class="hs-identifier hs-var">getSrcSpanDs</span></a></span><span>
</span><span id="line-193"></span><span>       </span><span class="annot"><span class="annottext">String
-&gt; SDoc
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (CoreExpr, CoreExpr -&gt; CoreExpr)
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;unboxArg: &quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681188675"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188723"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-194"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-195"></span><span>    </span><span id="local-6989586621681188723"><span class="annot"><span class="annottext">arg_ty :: Type
</span><a href="#local-6989586621681188723"><span class="hs-identifier hs-var hs-var">arg_ty</span></a></span></span><span>                                      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Type
</span><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier hs-var">exprType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188725"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-196"></span><span>    </span><span id="local-6989586621681188670"><span class="annot"><span class="annottext">maybe_product_type :: Maybe (TyCon, [Type], DataCon, [Scaled Type])
</span><a href="#local-6989586621681188670"><span class="hs-identifier hs-var hs-var">maybe_product_type</span></a></span></span><span>                          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (TyCon, [Type], DataCon, [Scaled Type])
</span><a href="GHC.Core.DataCon.html#splitDataProductType_maybe"><span class="hs-identifier hs-var">splitDataProductType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188723"><span class="hs-identifier hs-var">arg_ty</span></a></span><span>
</span><span id="line-197"></span><span>    </span><span id="local-6989586621681188701"><span class="annot"><span class="annottext">is_product_type :: Bool
</span><a href="#local-6989586621681188701"><span class="hs-identifier hs-var hs-var">is_product_type</span></a></span></span><span>                             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (TyCon, [Type], DataCon, [Scaled Type]) -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (TyCon, [Type], DataCon, [Scaled Type])
</span><a href="#local-6989586621681188670"><span class="hs-identifier hs-var">maybe_product_type</span></a></span><span>
</span><span id="line-198"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188691"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681188691"><span class="hs-identifier hs-var">data_con</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188668"><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681188668"><span class="hs-identifier hs-var">scaled_data_con_arg_tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (TyCon, [Type], DataCon, [Scaled Type])
</span><a href="#local-6989586621681188670"><span class="hs-identifier hs-var">maybe_product_type</span></a></span><span>
</span><span id="line-199"></span><span>    </span><span id="local-6989586621681188677"><span class="annot"><span class="annottext">data_con_arg_tys :: [Type]
</span><a href="#local-6989586621681188677"><span class="hs-identifier hs-var hs-var">data_con_arg_tys</span></a></span></span><span>                            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Scaled Type -&gt; Type) -&gt; [Scaled Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled Type -&gt; Type
forall a. Scaled a -&gt; a
</span><a href="GHC.Core.TyCo.Rep.html#scaledThing"><span class="hs-identifier hs-var">scaledThing</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681188668"><span class="hs-identifier hs-var">scaled_data_con_arg_tys</span></a></span><span>
</span><span id="line-200"></span><span>    </span><span id="local-6989586621681188700"><span class="annot"><span class="annottext">data_con_arity :: Int
</span><a href="#local-6989586621681188700"><span class="hs-identifier hs-var hs-var">data_con_arity</span></a></span></span><span>                              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; Int
</span><a href="GHC.Core.DataCon.html#dataConSourceArity"><span class="hs-identifier hs-var">dataConSourceArity</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681188691"><span class="hs-identifier hs-var">data_con</span></a></span><span>
</span><span id="line-201"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681188698"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188698"><span class="hs-identifier hs-var">data_con_arg_ty1</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>                      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681188677"><span class="hs-identifier hs-var">data_con_arg_tys</span></a></span><span>
</span><span id="line-202"></span><span>
</span><span id="line-203"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681188665"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188665"><span class="hs-identifier hs-var">data_con_arg_ty3</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681188677"><span class="hs-identifier hs-var">data_con_arg_tys</span></a></span><span>
</span><span id="line-204"></span><span>    </span><span id="local-6989586621681188689"><span class="annot"><span class="annottext">maybe_arg3_tycon :: Maybe TyCon
</span><a href="#local-6989586621681188689"><span class="hs-identifier hs-var hs-var">maybe_arg3_tycon</span></a></span></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe TyCon
</span><a href="GHC.Core.Type.html#tyConAppTyCon_maybe"><span class="hs-identifier hs-var">tyConAppTyCon_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188665"><span class="hs-identifier hs-var">data_con_arg_ty3</span></a></span><span>
</span><span id="line-205"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681188688"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188688"><span class="hs-identifier hs-var">arg3_tycon</span></a></span></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe TyCon
</span><a href="#local-6989586621681188689"><span class="hs-identifier hs-var">maybe_arg3_tycon</span></a></span><span>
</span><span id="line-206"></span><span>
</span><span id="line-207"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html#boxResult"><span class="hs-identifier hs-type">boxResult</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-208"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-209"></span><span>
</span><span id="line-210"></span><span class="hs-comment">-- Takes the result of the user-level ccall:</span><span>
</span><span id="line-211"></span><span class="hs-comment">--      either (IO t),</span><span>
</span><span id="line-212"></span><span class="hs-comment">--      or maybe just t for a side-effect-free call</span><span>
</span><span id="line-213"></span><span class="hs-comment">-- Returns a wrapper for the primitive ccall itself, along with the</span><span>
</span><span id="line-214"></span><span class="hs-comment">-- type of the result of the primitive ccall.  This result type</span><span>
</span><span id="line-215"></span><span class="hs-comment">-- will be of the form</span><span>
</span><span id="line-216"></span><span class="hs-comment">--      State# RealWorld -&gt; (# State# RealWorld, t' #)</span><span>
</span><span id="line-217"></span><span class="hs-comment">-- where t' is the unwrapped form of t.  If t is simply (), then</span><span>
</span><span id="line-218"></span><span class="hs-comment">-- the result type will be</span><span>
</span><span id="line-219"></span><span class="hs-comment">--      State# RealWorld -&gt; (# State# RealWorld #)</span><span>
</span><span id="line-220"></span><span>
</span><span id="line-221"></span><span id="boxResult"><span class="annot"><span class="annottext">boxResult :: Type -&gt; DsM (Type, CoreExpr -&gt; CoreExpr)
</span><a href="GHC.HsToCore.Foreign.Call.html#boxResult"><span class="hs-identifier hs-var hs-var">boxResult</span></a></span></span><span> </span><span id="local-6989586621681188664"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188664"><span class="hs-identifier hs-var">result_ty</span></a></span></span><span>
</span><span id="line-222"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681188663"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188663"><span class="hs-identifier hs-var">io_tycon</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188662"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188662"><span class="hs-identifier hs-var">io_res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (TyCon, Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitIOType_maybe"><span class="hs-identifier hs-var">tcSplitIOType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188664"><span class="hs-identifier hs-var">result_ty</span></a></span><span>
</span><span id="line-223"></span><span>        </span><span class="hs-comment">-- isIOType_maybe handles the case where the type is a</span><span>
</span><span id="line-224"></span><span>        </span><span class="hs-comment">-- simple wrapping of IO.  E.g.</span><span>
</span><span id="line-225"></span><span>        </span><span class="hs-comment">--      newtype Wrap a = W (IO a)</span><span>
</span><span id="line-226"></span><span>        </span><span class="hs-comment">-- No coercion necessary because its a non-recursive newtype</span><span>
</span><span id="line-227"></span><span>        </span><span class="hs-comment">-- (If we wanted to handle a *recursive* newtype too, we'd need</span><span>
</span><span id="line-228"></span><span>        </span><span class="hs-comment">-- another case, and a coercion.)</span><span>
</span><span id="line-229"></span><span>        </span><span class="hs-comment">-- The result is IO t, so wrap the result in an IO constructor</span><span>
</span><span id="line-230"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681188660"><span class="annot"><span class="annottext">(Maybe Type, CoreExpr -&gt; CoreExpr)
</span><a href="#local-6989586621681188660"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM (Maybe Type, CoreExpr -&gt; CoreExpr)
</span><a href="GHC.HsToCore.Foreign.Call.html#resultWrapper"><span class="hs-identifier hs-var">resultWrapper</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188662"><span class="hs-identifier hs-var">io_res_ty</span></a></span><span>
</span><span id="line-231"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681188659"><span class="annot"><span class="annottext">extra_result_tys :: [Type]
</span><a href="#local-6989586621681188659"><span class="hs-identifier hs-var hs-var">extra_result_tys</span></a></span></span><span>
</span><span id="line-232"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(Maybe Type, CoreExpr -&gt; CoreExpr)
</span><a href="#local-6989586621681188660"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-233"></span><span>                     </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681188658"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188658"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-234"></span><span>                       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Type.html#isUnboxedTupleType"><span class="hs-identifier hs-var">isUnboxedTupleType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188658"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-235"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681188656"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681188656"><span class="hs-identifier hs-var">ls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe [Type]
</span><a href="GHC.Core.Type.html#tyConAppArgs_maybe"><span class="hs-identifier hs-var">tyConAppArgs_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188658"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#tail"><span class="hs-identifier hs-var">tail</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681188656"><span class="hs-identifier hs-var">ls</span></a></span><span>
</span><span id="line-236"></span><span>                     </span><span class="annot"><span class="annottext">(Maybe Type, CoreExpr -&gt; CoreExpr)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-237"></span><span>
</span><span id="line-238"></span><span>              </span><span id="local-6989586621681188653"><span class="annot"><span class="annottext">return_result :: CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
</span><a href="#local-6989586621681188653"><span class="hs-identifier hs-var hs-var">return_result</span></a></span></span><span> </span><span id="local-6989586621681188652"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188652"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span id="local-6989586621681188651"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681188651"><span class="hs-identifier hs-var">anss</span></a></span></span><span>
</span><span id="line-239"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [CoreExpr] -&gt; CoreExpr
</span><a href="GHC.Core.Make.html#mkCoreUbxTup"><span class="hs-identifier hs-var">mkCoreUbxTup</span></a></span><span>
</span><span id="line-240"></span><span>                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#realWorldStatePrimTy"><span class="hs-identifier hs-var">realWorldStatePrimTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; [Type] -&gt; [Type]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188662"><span class="hs-identifier hs-var">io_res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; [Type] -&gt; [Type]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681188659"><span class="hs-identifier hs-var">extra_result_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-241"></span><span>                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188652"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681188651"><span class="hs-identifier hs-var">anss</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-242"></span><span>
</span><span id="line-243"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681188648"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188648"><span class="hs-identifier hs-var">ccall_res_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188647"><span class="annot"><span class="annottext">Alt Var
</span><a href="#local-6989586621681188647"><span class="hs-identifier hs-var">the_alt</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr)
-&gt; (Maybe Type, CoreExpr -&gt; CoreExpr) -&gt; DsM (Type, Alt Var)
</span><a href="GHC.HsToCore.Foreign.Call.html#mk_alt"><span class="hs-identifier hs-var">mk_alt</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
</span><a href="#local-6989586621681188653"><span class="hs-identifier hs-var">return_result</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Type, CoreExpr -&gt; CoreExpr)
</span><a href="#local-6989586621681188660"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-244"></span><span>
</span><span id="line-245"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681188645"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188645"><span class="hs-identifier hs-var">state_id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; DsM Var
</span><a href="GHC.HsToCore.Monad.html#newSysLocalDs"><span class="hs-identifier hs-var">newSysLocalDs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#realWorldStatePrimTy"><span class="hs-identifier hs-var">realWorldStatePrimTy</span></a></span><span>
</span><span id="line-246"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681188644"><span class="annot"><span class="annottext">io_data_con :: DataCon
</span><a href="#local-6989586621681188644"><span class="hs-identifier hs-var hs-var">io_data_con</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[DataCon] -&gt; DataCon
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [DataCon]
</span><a href="GHC.Core.TyCon.html#tyConDataCons"><span class="hs-identifier hs-var">tyConDataCons</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188663"><span class="hs-identifier hs-var">io_tycon</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-247"></span><span>              </span><span id="local-6989586621681188641"><span class="annot"><span class="annottext">toIOCon :: Var
</span><a href="#local-6989586621681188641"><span class="hs-identifier hs-var hs-var">toIOCon</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; Var
</span><a href="GHC.Core.DataCon.html#dataConWrapId"><span class="hs-identifier hs-var">dataConWrapId</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681188644"><span class="hs-identifier hs-var">io_data_con</span></a></span><span>
</span><span id="line-248"></span><span>
</span><span id="line-249"></span><span>              </span><span id="local-6989586621681188639"><span class="annot"><span class="annottext">wrap :: CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188639"><span class="hs-identifier hs-var hs-var">wrap</span></a></span></span><span> </span><span id="local-6989586621681188638"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188638"><span class="hs-identifier hs-var">the_call</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-250"></span><span>                              </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
forall b. Expr b -&gt; [Expr b] -&gt; Expr b
</span><a href="GHC.Core.html#mkApps"><span class="hs-identifier hs-var">mkApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188641"><span class="hs-identifier hs-var">toIOCon</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-251"></span><span>                                     </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Type -&gt; CoreExpr
forall b. Type -&gt; Expr b
</span><a href="GHC.Core.html#Type"><span class="hs-identifier hs-var">Type</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188662"><span class="hs-identifier hs-var">io_res_ty</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-252"></span><span>                                       </span><span class="annot"><span class="annottext">Var -&gt; CoreExpr -&gt; CoreExpr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188645"><span class="hs-identifier hs-var">state_id</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr) -&gt; CoreExpr -&gt; CoreExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-253"></span><span>                                       </span><span class="annot"><span class="annottext">CoreExpr -&gt; Scaled Type -&gt; Type -&gt; [Alt Var] -&gt; CoreExpr
</span><a href="GHC.Core.Make.html#mkWildCase"><span class="hs-identifier hs-var">mkWildCase</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr -&gt; CoreExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188638"><span class="hs-identifier hs-var">the_call</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188645"><span class="hs-identifier hs-var">state_id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-254"></span><span>                                             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Scaled Type
forall a. a -&gt; Scaled a
</span><a href="GHC.Core.Type.html#unrestricted"><span class="hs-identifier hs-var">unrestricted</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188648"><span class="hs-identifier hs-var">ccall_res_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-255"></span><span>                                             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Alt Var -&gt; Type
</span><a href="GHC.Core.Utils.html#coreAltType"><span class="hs-identifier hs-var">coreAltType</span></a></span><span> </span><span class="annot"><span class="annottext">Alt Var
</span><a href="#local-6989586621681188647"><span class="hs-identifier hs-var">the_alt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-256"></span><span>                                             </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Alt Var
</span><a href="#local-6989586621681188647"><span class="hs-identifier hs-var">the_alt</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-257"></span><span>                                     </span><span class="hs-special">]</span><span>
</span><span id="line-258"></span><span>
</span><span id="line-259"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Type, CoreExpr -&gt; CoreExpr) -&gt; DsM (Type, CoreExpr -&gt; CoreExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#realWorldStatePrimTy"><span class="hs-identifier hs-var">realWorldStatePrimTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTyMany"><span class="hs-operator hs-var">`mkVisFunTyMany`</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188648"><span class="hs-identifier hs-var">ccall_res_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188639"><span class="hs-identifier hs-var">wrap</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-260"></span><span>
</span><span id="line-261"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html#boxResult"><span class="hs-identifier hs-var">boxResult</span></a></span><span> </span><span id="local-6989586621681188631"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188631"><span class="hs-identifier hs-var">result_ty</span></a></span></span><span>
</span><span id="line-262"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-comment">-- It isn't IO, so do unsafePerformIO</span><span>
</span><span id="line-263"></span><span>       </span><span class="hs-comment">-- It's not conveniently available, so we inline it</span><span>
</span><span id="line-264"></span><span>       </span><span id="local-6989586621681188630"><span class="annot"><span class="annottext">(Maybe Type, CoreExpr -&gt; CoreExpr)
</span><a href="#local-6989586621681188630"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM (Maybe Type, CoreExpr -&gt; CoreExpr)
</span><a href="GHC.HsToCore.Foreign.Call.html#resultWrapper"><span class="hs-identifier hs-var">resultWrapper</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188631"><span class="hs-identifier hs-var">result_ty</span></a></span><span>
</span><span id="line-265"></span><span>       </span><span class="hs-special">(</span><span id="local-6989586621681188629"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188629"><span class="hs-identifier hs-var">ccall_res_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188628"><span class="annot"><span class="annottext">Alt Var
</span><a href="#local-6989586621681188628"><span class="hs-identifier hs-var">the_alt</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr)
-&gt; (Maybe Type, CoreExpr -&gt; CoreExpr) -&gt; DsM (Type, Alt Var)
</span><a href="GHC.HsToCore.Foreign.Call.html#mk_alt"><span class="hs-identifier hs-var">mk_alt</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
forall {p} {a}. p -&gt; [a] -&gt; a
</span><a href="#local-6989586621681188627"><span class="hs-identifier hs-var">return_result</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Type, CoreExpr -&gt; CoreExpr)
</span><a href="#local-6989586621681188630"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-266"></span><span>       </span><span class="hs-keyword">let</span><span>
</span><span id="line-267"></span><span>           </span><span id="local-6989586621681188626"><span class="annot"><span class="annottext">wrap :: CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188626"><span class="hs-identifier hs-var hs-var">wrap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621681188625"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188625"><span class="hs-identifier hs-var">the_call</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Scaled Type -&gt; Type -&gt; [Alt Var] -&gt; CoreExpr
</span><a href="GHC.Core.Make.html#mkWildCase"><span class="hs-identifier hs-var">mkWildCase</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr -&gt; CoreExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188625"><span class="hs-identifier hs-var">the_call</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="GHC.Types.Id.Make.html#realWorldPrimId"><span class="hs-identifier hs-var">realWorldPrimId</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-268"></span><span>                                           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Scaled Type
forall a. a -&gt; Scaled a
</span><a href="GHC.Core.Type.html#unrestricted"><span class="hs-identifier hs-var">unrestricted</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188629"><span class="hs-identifier hs-var">ccall_res_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-269"></span><span>                                           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Alt Var -&gt; Type
</span><a href="GHC.Core.Utils.html#coreAltType"><span class="hs-identifier hs-var">coreAltType</span></a></span><span> </span><span class="annot"><span class="annottext">Alt Var
</span><a href="#local-6989586621681188628"><span class="hs-identifier hs-var">the_alt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-270"></span><span>                                           </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Alt Var
</span><a href="#local-6989586621681188628"><span class="hs-identifier hs-var">the_alt</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-271"></span><span>       </span><span class="annot"><span class="annottext">(Type, CoreExpr -&gt; CoreExpr) -&gt; DsM (Type, CoreExpr -&gt; CoreExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#realWorldStatePrimTy"><span class="hs-identifier hs-var">realWorldStatePrimTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTyMany"><span class="hs-operator hs-var">`mkVisFunTyMany`</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188629"><span class="hs-identifier hs-var">ccall_res_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188626"><span class="hs-identifier hs-var">wrap</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-272"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-273"></span><span>    </span><span id="local-6989586621681188627"><span class="annot"><span class="annottext">return_result :: p -&gt; [a] -&gt; a
</span><a href="#local-6989586621681188627"><span class="hs-identifier hs-var hs-var">return_result</span></a></span></span><span> </span><span class="annot"><span class="annottext">p
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span id="local-6989586621681188623"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681188623"><span class="hs-identifier hs-var">ans</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681188623"><span class="hs-identifier hs-var">ans</span></a></span><span>
</span><span id="line-274"></span><span>    </span><span class="annot"><a href="#local-6989586621681188627"><span class="hs-identifier hs-var">return_result</span></a></span><span> </span><span class="annot"><span class="annottext">p
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[a]
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; a
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;return_result: expected single result&quot;</span></span><span>
</span><span id="line-275"></span><span>
</span><span id="line-276"></span><span>
</span><span id="line-277"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html#mk_alt"><span class="hs-identifier hs-type">mk_alt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Expr"><span class="hs-identifier hs-type">Expr</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#Expr"><span class="hs-identifier hs-type">Expr</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#Expr"><span class="hs-identifier hs-type">Expr</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-278"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#Expr"><span class="hs-identifier hs-type">Expr</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#Expr"><span class="hs-identifier hs-type">Expr</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-279"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#AltCon"><span class="hs-identifier hs-type">AltCon</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#Expr"><span class="hs-identifier hs-type">Expr</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-280"></span><span id="mk_alt"><span class="annot"><span class="annottext">mk_alt :: (CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr)
-&gt; (Maybe Type, CoreExpr -&gt; CoreExpr) -&gt; DsM (Type, Alt Var)
</span><a href="GHC.HsToCore.Foreign.Call.html#mk_alt"><span class="hs-identifier hs-var hs-var">mk_alt</span></a></span></span><span> </span><span id="local-6989586621681188621"><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
</span><a href="#local-6989586621681188621"><span class="hs-identifier hs-var">return_result</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Type
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188620"><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188620"><span class="hs-identifier hs-var">wrap_result</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-281"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-comment">-- The ccall returns ()</span><span>
</span><span id="line-282"></span><span>       </span><span id="local-6989586621681188619"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188619"><span class="hs-identifier hs-var">state_id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; DsM Var
</span><a href="GHC.HsToCore.Monad.html#newSysLocalDs"><span class="hs-identifier hs-var">newSysLocalDs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#realWorldStatePrimTy"><span class="hs-identifier hs-var">realWorldStatePrimTy</span></a></span><span>
</span><span id="line-283"></span><span>       </span><span class="hs-keyword">let</span><span>
</span><span id="line-284"></span><span>             </span><span id="local-6989586621681188618"><span class="annot"><span class="annottext">the_rhs :: CoreExpr
</span><a href="#local-6989586621681188618"><span class="hs-identifier hs-var hs-var">the_rhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
</span><a href="#local-6989586621681188621"><span class="hs-identifier hs-var">return_result</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188619"><span class="hs-identifier hs-var">state_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-285"></span><span>                                     </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188620"><span class="hs-identifier hs-var">wrap_result</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CoreExpr
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;boxResult&quot;</span></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-286"></span><span>
</span><span id="line-287"></span><span>             </span><span id="local-6989586621681188617"><span class="annot"><span class="annottext">ccall_res_ty :: Type
</span><a href="#local-6989586621681188617"><span class="hs-identifier hs-var hs-var">ccall_res_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Boxity -&gt; [Type] -&gt; Type
</span><a href="GHC.Builtin.Types.html#mkTupleTy"><span class="hs-identifier hs-var">mkTupleTy</span></a></span><span> </span><span class="annot"><span class="annottext">Boxity
</span><a href="GHC.Types.Basic.html#Unboxed"><span class="hs-identifier hs-var">Unboxed</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#realWorldStatePrimTy"><span class="hs-identifier hs-var">realWorldStatePrimTy</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-288"></span><span>             </span><span id="local-6989586621681188614"><span class="annot"><span class="annottext">the_alt :: Alt Var
</span><a href="#local-6989586621681188614"><span class="hs-identifier hs-var hs-var">the_alt</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; AltCon
</span><a href="GHC.Core.html#DataAlt"><span class="hs-identifier hs-var">DataAlt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Boxity -&gt; Int -&gt; DataCon
</span><a href="GHC.Builtin.Types.html#tupleDataCon"><span class="hs-identifier hs-var">tupleDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">Boxity
</span><a href="GHC.Types.Basic.html#Unboxed"><span class="hs-identifier hs-var">Unboxed</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188619"><span class="hs-identifier hs-var">state_id</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188618"><span class="hs-identifier hs-var">the_rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-289"></span><span>
</span><span id="line-290"></span><span>       </span><span class="annot"><span class="annottext">(Type, Alt Var) -&gt; DsM (Type, Alt Var)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188617"><span class="hs-identifier hs-var">ccall_res_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Alt Var
</span><a href="#local-6989586621681188614"><span class="hs-identifier hs-var">the_alt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-291"></span><span>
</span><span id="line-292"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html#mk_alt"><span class="hs-identifier hs-var">mk_alt</span></a></span><span> </span><span id="local-6989586621681188612"><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
</span><a href="#local-6989586621681188612"><span class="hs-identifier hs-var">return_result</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681188611"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188611"><span class="hs-identifier hs-var">prim_res_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188610"><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188610"><span class="hs-identifier hs-var">wrap_result</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-293"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- The ccall returns a non-() value</span><span>
</span><span id="line-294"></span><span>    </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isPrimitiveType</span><span> </span><span class="hs-identifier">prim_res_ty</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">prim_res_ty</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-295"></span><span>             </span><span class="hs-comment">-- True because resultWrapper ensures it is so</span><span>
</span><span id="line-296"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681188609"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188609"><span class="hs-identifier hs-var">result_id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; DsM Var
</span><a href="GHC.HsToCore.Monad.html#newSysLocalDs"><span class="hs-identifier hs-var">newSysLocalDs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188611"><span class="hs-identifier hs-var">prim_res_ty</span></a></span><span>
</span><span id="line-297"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681188608"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188608"><span class="hs-identifier hs-var">state_id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; DsM Var
</span><a href="GHC.HsToCore.Monad.html#newSysLocalDs"><span class="hs-identifier hs-var">newSysLocalDs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#realWorldStatePrimTy"><span class="hs-identifier hs-var">realWorldStatePrimTy</span></a></span><span>
</span><span id="line-298"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681188607"><span class="annot"><span class="annottext">the_rhs :: CoreExpr
</span><a href="#local-6989586621681188607"><span class="hs-identifier hs-var hs-var">the_rhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
</span><a href="#local-6989586621681188612"><span class="hs-identifier hs-var">return_result</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188608"><span class="hs-identifier hs-var">state_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-299"></span><span>                                </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188610"><span class="hs-identifier hs-var">wrap_result</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188609"><span class="hs-identifier hs-var">result_id</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-300"></span><span>             </span><span id="local-6989586621681188606"><span class="annot"><span class="annottext">ccall_res_ty :: Type
</span><a href="#local-6989586621681188606"><span class="hs-identifier hs-var hs-var">ccall_res_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Boxity -&gt; [Type] -&gt; Type
</span><a href="GHC.Builtin.Types.html#mkTupleTy"><span class="hs-identifier hs-var">mkTupleTy</span></a></span><span> </span><span class="annot"><span class="annottext">Boxity
</span><a href="GHC.Types.Basic.html#Unboxed"><span class="hs-identifier hs-var">Unboxed</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#realWorldStatePrimTy"><span class="hs-identifier hs-var">realWorldStatePrimTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188611"><span class="hs-identifier hs-var">prim_res_ty</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-301"></span><span>             </span><span id="local-6989586621681188605"><span class="annot"><span class="annottext">the_alt :: Alt Var
</span><a href="#local-6989586621681188605"><span class="hs-identifier hs-var hs-var">the_alt</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; AltCon
</span><a href="GHC.Core.html#DataAlt"><span class="hs-identifier hs-var">DataAlt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Boxity -&gt; Int -&gt; DataCon
</span><a href="GHC.Builtin.Types.html#tupleDataCon"><span class="hs-identifier hs-var">tupleDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">Boxity
</span><a href="GHC.Types.Basic.html#Unboxed"><span class="hs-identifier hs-var">Unboxed</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188608"><span class="hs-identifier hs-var">state_id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188609"><span class="hs-identifier hs-var">result_id</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188607"><span class="hs-identifier hs-var">the_rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-302"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Type, Alt Var) -&gt; DsM (Type, Alt Var)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188606"><span class="hs-identifier hs-var">ccall_res_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Alt Var
</span><a href="#local-6989586621681188605"><span class="hs-identifier hs-var">the_alt</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-303"></span><span>
</span><span id="line-304"></span><span>
</span><span id="line-305"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html#resultWrapper"><span class="hs-identifier hs-type">resultWrapper</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-306"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span>               </span><span class="hs-comment">-- Type of the expected result, if any</span><span>
</span><span id="line-307"></span><span>                      </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span>     </span><span class="hs-comment">-- Wrapper for the result</span><span>
</span><span id="line-308"></span><span class="hs-comment">-- resultWrapper deals with the result *value*</span><span>
</span><span id="line-309"></span><span class="hs-comment">-- E.g. foreign import foo :: Int -&gt; IO T</span><span>
</span><span id="line-310"></span><span class="hs-comment">-- Then resultWrapper deals with marshalling the 'T' part</span><span>
</span><span id="line-311"></span><span class="hs-comment">-- So if    resultWrapper ty = (Just ty_rep, marshal)</span><span>
</span><span id="line-312"></span><span class="hs-comment">--  then      marshal (e :: ty_rep) :: ty</span><span>
</span><span id="line-313"></span><span class="hs-comment">-- That is, 'marshal' wrape the result returned by the foreign call,</span><span>
</span><span id="line-314"></span><span class="hs-comment">-- of type ty_rep, into the value Haskell expected, of type 'ty'</span><span>
</span><span id="line-315"></span><span class="hs-comment">--</span><span>
</span><span id="line-316"></span><span class="hs-comment">-- Invariant: ty_rep is always a primitive type</span><span>
</span><span id="line-317"></span><span class="hs-comment">--            i.e. (isPrimitiveType ty_rep) is True</span><span>
</span><span id="line-318"></span><span>
</span><span id="line-319"></span><span id="resultWrapper"><span class="annot"><span class="annottext">resultWrapper :: Type -&gt; DsM (Maybe Type, CoreExpr -&gt; CoreExpr)
</span><a href="GHC.HsToCore.Foreign.Call.html#resultWrapper"><span class="hs-identifier hs-var hs-var">resultWrapper</span></a></span></span><span> </span><span id="local-6989586621681188604"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188604"><span class="hs-identifier hs-var">result_ty</span></a></span></span><span>
</span><span id="line-320"></span><span>  </span><span class="hs-comment">-- Base case 1: primitive types</span><span>
</span><span id="line-321"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Type.html#isPrimitiveType"><span class="hs-identifier hs-var">isPrimitiveType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188604"><span class="hs-identifier hs-var">result_ty</span></a></span><span>
</span><span id="line-322"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Maybe Type, CoreExpr -&gt; CoreExpr)
-&gt; DsM (Maybe Type, CoreExpr -&gt; CoreExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Maybe Type
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188604"><span class="hs-identifier hs-var">result_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681188603"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188603"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188603"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-323"></span><span>
</span><span id="line-324"></span><span>  </span><span class="hs-comment">-- Base case 2: the unit type ()</span><span>
</span><span id="line-325"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681188602"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188602"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (TyCon, [Type])
</span><a href="#local-6989586621681188601"><span class="hs-identifier hs-var">maybe_tc_app</span></a></span><span>
</span><span id="line-326"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188602"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Types.html#unitTyConKey"><span class="hs-identifier hs-var">unitTyConKey</span></a></span><span>
</span><span id="line-327"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Maybe Type, CoreExpr -&gt; CoreExpr)
-&gt; DsM (Maybe Type, CoreExpr -&gt; CoreExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Type
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="GHC.Core.Make.html#unitExpr"><span class="hs-identifier hs-var">unitExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-328"></span><span>
</span><span id="line-329"></span><span>  </span><span class="hs-comment">-- Base case 3: the boolean type</span><span>
</span><span id="line-330"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681188598"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188598"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (TyCon, [Type])
</span><a href="#local-6989586621681188601"><span class="hs-identifier hs-var">maybe_tc_app</span></a></span><span>
</span><span id="line-331"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188598"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#boolTyConKey"><span class="hs-identifier hs-var">boolTyConKey</span></a></span><span>
</span><span id="line-332"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681188597"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681188597"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-333"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681188596"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681188596"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681188597"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-334"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681188595"><span class="annot"><span class="annottext">marshal_bool :: CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188595"><span class="hs-identifier hs-var hs-var">marshal_bool</span></a></span></span><span> </span><span id="local-6989586621681188594"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188594"><span class="hs-identifier hs-var">e</span></a></span></span><span>
</span><span id="line-335"></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Scaled Type -&gt; Type -&gt; [Alt Var] -&gt; CoreExpr
</span><a href="GHC.Core.Make.html#mkWildCase"><span class="hs-identifier hs-var">mkWildCase</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188594"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Scaled Type
forall a. a -&gt; Scaled a
</span><a href="GHC.Core.Type.html#unrestricted"><span class="hs-identifier hs-var">unrestricted</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#intPrimTy"><span class="hs-identifier hs-var">intPrimTy</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#boolTy"><span class="hs-identifier hs-var">boolTy</span></a></span><span>
</span><span id="line-336"></span><span>                   </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="GHC.Core.html#DEFAULT"><span class="hs-identifier hs-var">DEFAULT</span></a></span><span>                     </span><span class="hs-special">,</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="GHC.Builtin.Types.html#trueDataConId"><span class="hs-identifier hs-var">trueDataConId</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-337"></span><span>                   </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Literal -&gt; AltCon
</span><a href="GHC.Core.html#LitAlt"><span class="hs-identifier hs-var">LitAlt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Integer -&gt; Literal
</span><a href="GHC.Types.Literal.html#mkLitInt"><span class="hs-identifier hs-var">mkLitInt</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681188596"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="GHC.Builtin.Types.html#falseDataConId"><span class="hs-identifier hs-var">falseDataConId</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-338"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Maybe Type, CoreExpr -&gt; CoreExpr)
-&gt; DsM (Maybe Type, CoreExpr -&gt; CoreExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Maybe Type
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.Prim.html#intPrimTy"><span class="hs-identifier hs-var">intPrimTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188595"><span class="hs-identifier hs-var">marshal_bool</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-339"></span><span>
</span><span id="line-340"></span><span>  </span><span class="hs-comment">-- Newtypes</span><span>
</span><span id="line-341"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681188588"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188588"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188587"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188587"><span class="hs-identifier hs-var">rep_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Coercion, Type)
</span><a href="GHC.Core.Coercion.html#topNormaliseNewType_maybe"><span class="hs-identifier hs-var">topNormaliseNewType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188604"><span class="hs-identifier hs-var">result_ty</span></a></span><span>
</span><span id="line-342"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681188586"><span class="annot"><span class="annottext">Maybe Type
</span><a href="#local-6989586621681188586"><span class="hs-identifier hs-var">maybe_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188585"><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188585"><span class="hs-identifier hs-var">wrapper</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM (Maybe Type, CoreExpr -&gt; CoreExpr)
</span><a href="GHC.HsToCore.Foreign.Call.html#resultWrapper"><span class="hs-identifier hs-var">resultWrapper</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188587"><span class="hs-identifier hs-var">rep_ty</span></a></span><span>
</span><span id="line-343"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Maybe Type, CoreExpr -&gt; CoreExpr)
-&gt; DsM (Maybe Type, CoreExpr -&gt; CoreExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Type
</span><a href="#local-6989586621681188586"><span class="hs-identifier hs-var">maybe_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681188584"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188584"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Coercion -&gt; CoreExpr
</span><a href="GHC.HsToCore.Utils.html#mkCastDs"><span class="hs-identifier hs-var">mkCastDs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188585"><span class="hs-identifier hs-var">wrapper</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188584"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681188588"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-344"></span><span>
</span><span id="line-345"></span><span>  </span><span class="hs-comment">-- The type might contain foralls (eg. for dummy type arguments,</span><span>
</span><span id="line-346"></span><span>  </span><span class="hs-comment">-- referring to 'Ptr a' is legal).</span><span>
</span><span id="line-347"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681188582"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188582"><span class="hs-identifier hs-var">tyvar</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188581"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188581"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Var, Type)
</span><a href="GHC.Core.Type.html#splitForAllTy_maybe"><span class="hs-identifier hs-var">splitForAllTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188604"><span class="hs-identifier hs-var">result_ty</span></a></span><span>
</span><span id="line-348"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681188579"><span class="annot"><span class="annottext">Maybe Type
</span><a href="#local-6989586621681188579"><span class="hs-identifier hs-var">maybe_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188578"><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188578"><span class="hs-identifier hs-var">wrapper</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM (Maybe Type, CoreExpr -&gt; CoreExpr)
</span><a href="GHC.HsToCore.Foreign.Call.html#resultWrapper"><span class="hs-identifier hs-var">resultWrapper</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188581"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-349"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Maybe Type, CoreExpr -&gt; CoreExpr)
-&gt; DsM (Maybe Type, CoreExpr -&gt; CoreExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Type
</span><a href="#local-6989586621681188579"><span class="hs-identifier hs-var">maybe_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681188577"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188577"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Var -&gt; CoreExpr -&gt; CoreExpr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621681188582"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188578"><span class="hs-identifier hs-var">wrapper</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188577"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-350"></span><span>
</span><span id="line-351"></span><span>  </span><span class="hs-comment">-- Data types with a single constructor, which has a single arg</span><span>
</span><span id="line-352"></span><span>  </span><span class="hs-comment">-- This includes types like Ptr and ForeignPtr</span><span>
</span><span id="line-353"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681188576"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188576"><span class="hs-identifier hs-var">tycon</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188575"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681188575"><span class="hs-identifier hs-var">tycon_arg_tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (TyCon, [Type])
</span><a href="#local-6989586621681188601"><span class="hs-identifier hs-var">maybe_tc_app</span></a></span><span>
</span><span id="line-354"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681188574"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681188574"><span class="hs-identifier hs-var">data_con</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe DataCon
</span><a href="GHC.Core.TyCon.html#isDataProductTyCon_maybe"><span class="hs-identifier hs-var">isDataProductTyCon_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188576"><span class="hs-identifier hs-var">tycon</span></a></span><span>  </span><span class="hs-comment">-- One constructor, no existentials</span><span>
</span><span id="line-355"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681188571"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188571"><span class="hs-identifier hs-var">unwrapped_res_ty</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; [Type] -&gt; [Scaled Type]
</span><a href="GHC.Core.DataCon.html#dataConInstOrigArgTys"><span class="hs-identifier hs-var">dataConInstOrigArgTys</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681188574"><span class="hs-identifier hs-var">data_con</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681188575"><span class="hs-identifier hs-var">tycon_arg_tys</span></a></span><span>  </span><span class="hs-comment">-- One argument</span><span>
</span><span id="line-356"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681188569"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681188569"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-357"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681188568"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681188568"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681188569"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-358"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681188567"><span class="annot"><span class="annottext">Maybe Type
</span><a href="#local-6989586621681188567"><span class="hs-identifier hs-var">maybe_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681188566"><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188566"><span class="hs-identifier hs-var">wrapper</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM (Maybe Type, CoreExpr -&gt; CoreExpr)
</span><a href="GHC.HsToCore.Foreign.Call.html#resultWrapper"><span class="hs-identifier hs-var">resultWrapper</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188571"><span class="hs-identifier hs-var">unwrapped_res_ty</span></a></span><span>
</span><span id="line-359"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681188565"><span class="annot"><span class="annottext">narrow_wrapper :: CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188565"><span class="hs-identifier hs-var hs-var">narrow_wrapper</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; TyCon -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.HsToCore.Foreign.Call.html#maybeNarrow"><span class="hs-identifier hs-var">maybeNarrow</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681188568"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188576"><span class="hs-identifier hs-var">tycon</span></a></span><span>
</span><span id="line-360"></span><span>             </span><span id="local-6989586621681188563"><span class="annot"><span class="annottext">marshal_con :: CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188563"><span class="hs-identifier hs-var hs-var">marshal_con</span></a></span></span><span> </span><span id="local-6989586621681188562"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188562"><span class="hs-identifier hs-var">e</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; Var
</span><a href="GHC.Core.DataCon.html#dataConWrapId"><span class="hs-identifier hs-var">dataConWrapId</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681188574"><span class="hs-identifier hs-var">data_con</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-361"></span><span>                              </span><span class="annot"><span class="annottext">CoreExpr -&gt; [Type] -&gt; CoreExpr
forall b. Expr b -&gt; [Type] -&gt; Expr b
</span><a href="GHC.Core.html#mkTyApps"><span class="hs-operator hs-var">`mkTyApps`</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681188575"><span class="hs-identifier hs-var">tycon_arg_tys</span></a></span><span>
</span><span id="line-362"></span><span>                              </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr -&gt; CoreExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-operator hs-var">`App`</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188566"><span class="hs-identifier hs-var">wrapper</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188565"><span class="hs-identifier hs-var">narrow_wrapper</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188562"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-363"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Maybe Type, CoreExpr -&gt; CoreExpr)
-&gt; DsM (Maybe Type, CoreExpr -&gt; CoreExpr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Type
</span><a href="#local-6989586621681188567"><span class="hs-identifier hs-var">maybe_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621681188563"><span class="hs-identifier hs-var">marshal_con</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-364"></span><span>
</span><span id="line-365"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-366"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; DsM (Maybe Type, CoreExpr -&gt; CoreExpr)
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;resultWrapper&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188604"><span class="hs-identifier hs-var">result_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-367"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-368"></span><span>    </span><span id="local-6989586621681188601"><span class="annot"><span class="annottext">maybe_tc_app :: Maybe (TyCon, [Type])
</span><a href="#local-6989586621681188601"><span class="hs-identifier hs-var hs-var">maybe_tc_app</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681188604"><span class="hs-identifier hs-var">result_ty</span></a></span><span>
</span><span id="line-369"></span><span>
</span><span id="line-370"></span><span class="hs-comment">-- When the result of a foreign call is smaller than the word size, we</span><span>
</span><span id="line-371"></span><span class="hs-comment">-- need to sign- or zero-extend the result up to the word size.  The C</span><span>
</span><span id="line-372"></span><span class="hs-comment">-- standard appears to say that this is the responsibility of the</span><span>
</span><span id="line-373"></span><span class="hs-comment">-- caller, not the callee.</span><span>
</span><span id="line-374"></span><span>
</span><span id="line-375"></span><span class="annot"><a href="GHC.HsToCore.Foreign.Call.html#maybeNarrow"><span class="hs-identifier hs-type">maybeNarrow</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-376"></span><span id="maybeNarrow"><span class="annot"><span class="annottext">maybeNarrow :: Platform -&gt; TyCon -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.HsToCore.Foreign.Call.html#maybeNarrow"><span class="hs-identifier hs-var hs-var">maybeNarrow</span></a></span></span><span> </span><span id="local-6989586621681188558"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681188558"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681188557"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188557"><span class="hs-identifier hs-var">tycon</span></a></span></span><span>
</span><span id="line-377"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188557"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#int8TyConKey"><span class="hs-identifier hs-var">int8TyConKey</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681188555"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188555"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr -&gt; CoreExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PrimOp -&gt; Var
</span><a href="GHC.Types.Id.Make.html#mkPrimOpId"><span class="hs-identifier hs-var">mkPrimOpId</span></a></span><span> </span><span class="annot"><span class="annottext">PrimOp
</span><a href="GHC.Builtin.PrimOps.html#Narrow8IntOp"><span class="hs-identifier hs-var">Narrow8IntOp</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188555"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-378"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188557"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#int16TyConKey"><span class="hs-identifier hs-var">int16TyConKey</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681188551"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188551"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr -&gt; CoreExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PrimOp -&gt; Var
</span><a href="GHC.Types.Id.Make.html#mkPrimOpId"><span class="hs-identifier hs-var">mkPrimOpId</span></a></span><span> </span><span class="annot"><span class="annottext">PrimOp
</span><a href="GHC.Builtin.PrimOps.html#Narrow16IntOp"><span class="hs-identifier hs-var">Narrow16IntOp</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188551"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-379"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188557"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#int32TyConKey"><span class="hs-identifier hs-var">int32TyConKey</span></a></span><span>
</span><span id="line-380"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Int
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformWordSizeInBytes"><span class="hs-identifier hs-var">platformWordSizeInBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681188558"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">4</span></span><span>
</span><span id="line-381"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681188546"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188546"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr -&gt; CoreExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PrimOp -&gt; Var
</span><a href="GHC.Types.Id.Make.html#mkPrimOpId"><span class="hs-identifier hs-var">mkPrimOpId</span></a></span><span> </span><span class="annot"><span class="annottext">PrimOp
</span><a href="GHC.Builtin.PrimOps.html#Narrow32IntOp"><span class="hs-identifier hs-var">Narrow32IntOp</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188546"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-382"></span><span>
</span><span id="line-383"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188557"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#word8TyConKey"><span class="hs-identifier hs-var">word8TyConKey</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681188543"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188543"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr -&gt; CoreExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PrimOp -&gt; Var
</span><a href="GHC.Types.Id.Make.html#mkPrimOpId"><span class="hs-identifier hs-var">mkPrimOpId</span></a></span><span> </span><span class="annot"><span class="annottext">PrimOp
</span><a href="GHC.Builtin.PrimOps.html#Narrow8WordOp"><span class="hs-identifier hs-var">Narrow8WordOp</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188543"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-384"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188557"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#word16TyConKey"><span class="hs-identifier hs-var">word16TyConKey</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681188540"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188540"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr -&gt; CoreExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PrimOp -&gt; Var
</span><a href="GHC.Types.Id.Make.html#mkPrimOpId"><span class="hs-identifier hs-var">mkPrimOpId</span></a></span><span> </span><span class="annot"><span class="annottext">PrimOp
</span><a href="GHC.Builtin.PrimOps.html#Narrow16WordOp"><span class="hs-identifier hs-var">Narrow16WordOp</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188540"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-385"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681188557"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#word32TyConKey"><span class="hs-identifier hs-var">word32TyConKey</span></a></span><span>
</span><span id="line-386"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Int
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformWordSizeInBytes"><span class="hs-identifier hs-var">platformWordSizeInBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681188558"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">4</span></span><span>
</span><span id="line-387"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681188537"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188537"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr -&gt; CoreExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var -&gt; CoreExpr
forall b. Var -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PrimOp -&gt; Var
</span><a href="GHC.Types.Id.Make.html#mkPrimOpId"><span class="hs-identifier hs-var">mkPrimOpId</span></a></span><span> </span><span class="annot"><span class="annottext">PrimOp
</span><a href="GHC.Builtin.PrimOps.html#Narrow32WordOp"><span class="hs-identifier hs-var">Narrow32WordOp</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681188537"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-388"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-389"></span></pre></body></html>